package com.tzstcl.sys.user.ctrl;

import com.tzstcl.base.ctrl.BaseCtrl;
import com.tzstcl.base.model.AjaxResult;
import com.tzstcl.sys.user.model.SysPost;
import com.tzstcl.sys.user.service.impl.SysPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 部门机构控制器
 *
 * @author haocj
 */
@Controller
@RequestMapping(value = "/admin/sysPost")
public class SysPostCtrl extends BaseCtrl {

    @Autowired
    private SysPostService sysPostService;

    @RequestMapping(value = "/info")
    @ResponseBody
    public List<SysPost> list(SysPost sysPost) {
        return sysPostService.findListAll(sysPost);
    }


    @RequestMapping(value = "/getById")
    @ResponseBody
    public SysPost getById(SysPost sysPost) {
        SysPost dept = sysPostService.get(sysPost);
        return dept;
    }

    /**
     * 新增 修改
     *
     * @param sysPost
     * @return
     */
    @RequestMapping(value = "/save")
    @ResponseBody
    public AjaxResult save(SysPost sysPost) {
        sysPostService.save(sysPost);
        return AjaxResult.success("success");
    }

    /**
     * 删除
     *
     * @param ids
     * @return
     */
    @RequestMapping(value = "/delete")
    @ResponseBody
    public AjaxResult delete(@RequestParam("ids") String[] ids) {
        return toAjax(sysPostService.delete(ids));
    }

}
